package it.secse.idmadaption.policy;

import it.secse.idmadaption.util.Constants;

import java.io.File;
import java.io.FileNotFoundException;

import javax.xml.stream.XMLStreamException;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;

public class PolicyDiscover {
	
	
    public static PolicyWrapper getPolicy(String opName) throws FileNotFoundException, XMLStreamException  {
        StAXOMBuilder builder = new StAXOMBuilder(Constants.DEFAULT_DIR + File.separator + opName + Constants.XML_EXTENSION);
//        OMNode app1 = elem.getFirstElement().getFirstElement().getFirstElement().getNextOMSibling().getNextOMSibling().getNextOMSibling().getNextOMSibling();
//        app1.serialize(System.out);
//        System.out.println("ECCO:  " + ((OMTextImpl)elem.getFirstChildWithName(new QName("http://schemas.xmlsoap.org/ws/2005/07/securitypolicy","TransportBinding","sp"))).getText());
        return new PolicyWrapper(builder.getDocumentElement());
        
    }


}
